<?php
/*
require_once('parameters.php');
// Désactivation du cache WSDL
ini_set('soap.wsdl_cache_enabled', 0);

// suite de votre script
?>
<?php

// Nouveau Client SOAP
try {
    // Nouvelle instance de la classe soapClient
    $client = new SoapClient('http://localhost/trunk/modules/webservices/def.wdsl', array(
    	'login' => $PARAMS['HTTP_AUTH_LOGIN'],
    	'password' => $PARAMS['HTTP_AUTH_PASSWORD']
    ));
   
    // appel de la méthode getServerDate du service web
    $O =  $client -> __call('getServerDate', array());
    // Affichage du résultat
    echo $O->date ;
} catch (SoapFault $fault) {
    echo $fault;
}
die;*/
?>

<?

/////////////

//loading useful functions...
include_once('functions.php');

//TODO products sample data...
$products = array (
	1 => array(
		'id' => 1,
		'name' => array(
			0 => 'The Ipod Nano',
			1 => 'L\'Ipod Nano'
		),
		'active' => true,
		'manufacturer_id' => 0,
		'supplier_id' => 0,
		'reference' => 'IPODNANO2009',
		'manufacturer_reference' => 'REF-0285758',
		'weight' => 17.6,
		'ean13' => 456789468713874,
		'position'=> 'Quelque part...',
		'image_name' => '2-47-home.jpg',
		'categories' => array(1,4)
	),
	10 => array(
		'id' => 10,
		'name' => array(
			0 => 'The Ipod Shuffle',
			1 => 'L\'Ipod Shuffle'
		),
		'active' => false,
		'manufacturer_id' => 1,
		'supplier_id' => 1,
		'reference' => 'IPODSHUFFLE2007',
		'manufacturer_reference' => 'REF-4565456',
		'weight' => 5.6,
		'ean13' => 123321321878979,
		'position'=> 'Par ici...',
		'image_name' => '2-47-home.jpg',
		'categories' => array(1,2,3)
	)
);

//parameters to fill...
$lang_id = null;
$current_product_id = null;
$languages_list = null;
$manufacturer_list = null;
$supplier_list = null;
$categories_containing_product = null;

//general construction....
$glade = new GladeXML(dirname(__FILE__) . '/ps_bo.glade');
$glade->signal_autoconnect();
$window = $glade->get_widget('prestashop-gtk-plus');
$window->connect_simple('destroy', array('Gtk', 'main_quit'));
 
//Get the widget object and connect the clicked signal...
$btnFirstProduct = $glade->get_widget('btnFirstProduct')->connect_simple('clicked', 'loadFirstProduct');
$btnPreviousProduct = $glade->get_widget('btnPreviousProduct')->connect_simple('clicked', 'loadPreviousProduct');
$btnNextProduct = $glade->get_widget('btnNextProduct')->connect_simple('clicked', 'loadNextProduct');
$btnLastProduct = $glade->get_widget('btnLastProduct')->connect_simple('clicked', 'loadLastProduct');

$glade->get_widget('btnSave')->connect_simple('clicked', 'saveProduct');
 

//TODO actions to do.....
function saveProduct() {
	//TODO
    Gtk::main_quit();
}
function loadFirstProduct()
{
	loadProduct('1');
}
function loadPreviousProduct() {
	//TODO
}
function loadNextProduct() {
	//TODO
}
function loadLastProduct() {
	loadProduct(10);//TODO get reel....
}

function loadProduct($id)
{
	global $glade,$products,$lang_id, $current_product_id;
	$current_product_id = $id;
	$product = $products[$id];
	
	$step = 's1_s1';//TODO
	
	//TODO load image
	/*
	$img = GtkImage::new_from_file('2-47-home.jpg');
	$img_container = $glade->get_widget('image_container');
	$img->set_parent($img_container);
	*/
	
	if ($step == 's1_s1')
	{
		require_once('steps/informations/general.php');
		load_s1_s1 ($product);
	}
	elseif ($step == 's1_s2')
	{
		require_once('steps/informations/images.php');
	}
	else
		echo 'error when choosing step.';
	$catalog_listing = $glade->get_widget('catalog_listing');
	$categories_containing_product = array(
			// id  id_parent name               active
		array(1, 0,            'Accueil'),
		array(3, 1,             'Accessoires'),
		array(2, 1,             'iPods'),
		array(4, 1,             'Portables')
	);
	$selected_categories = $product['categories'];
	loadCatalogList($catalog_listing, $categories_containing_product, $selected_categories);
}

//Start the main loop
loadGlobalParameters();
loadFirstProduct();

Gtk::main();

?>
